<?php

class M_poli extends CI_Model{

    public function getAllPoli() {
        $strSql = "SELECT * FROM tb_poliklinik";
        $strQuery = $this->db->query($strSql);
        if ($strQuery->num_rows() > 0) {
            foreach ($strQuery->result_array() as $val) {
                $arrHasil[] = $val;
            }
            $strQuery->free_result();
            return $arrHasil;
        } else {
            return array();
        }
    }

    public function getAllPoliWithLimit($pArrParam) {
        $strSql = "SELECT * FROM tb_poliklinik LIMIT ?,?";
        $strQuery = $this->db->query($strSql, $pArrParam);
        if ($strQuery->num_rows() > 0) {
            foreach ($strQuery->result_array() as $val) {
                $arrHasil[] = $val;
            }
            $strQuery->free_result();
            return $arrHasil;
        } else {
            return array();
        }
    }

    public function getPoli($pIntPoliklinikId) {
        $strSql = "SELECT * FROM tb_poliklinik WHERE id_poli=?";
        $strQuery = $this->db->query($strSql, $pIntPoliklinikId);
         if ($strQuery->num_rows() > 0) {
            $arrResult = $strQuery->row_array();
            $strQuery->free_result();
            return $arrResult;
        } else {
            return array();
        }
    }
    public function saveAdd($pArrParams) {
        $strSql = "INSERT INTO tb_poliklinik(nama) VALUES (?)";
         return $this->db->query($strSql, $pArrParams);
    }
    public function saveEdit($pArrParams) {
        $strSql = "UPDATE tb_poliklinik SET nama=? WHERE id_poli=?";
        return $this->db->query($strSql, $pArrParams);
    }
    function delete($pStrDokterId) {
        $strSql = "DELETE FROM tb_poliklinik WHERE id_poli=?";
        return $this->db->query($strSql, $pStrDokterId);
    }
    function count() {
        return $this->db->count_all_results("tb_poliklinik");
    }
}

?>
